package com.nf.health.app.intervention_details.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nf.health.app.R;
import com.nf.health.app.adapter.ViewHolder;
import com.nf.health.app.customview.CircleImageView;
import com.nf.health.app.intervention_details.bean.PrescriptionBean;
import com.nf.health.app.models.SchemeHistoryBean;
import com.nf.health.app.utils.ImageLoaderUtils;

import java.util.List;

/**
 * Created by 恩福 on 2016/11/10.
 * 历史方案Adapter
 */

public class PrescriptionAdapter extends BaseAdapter {

    List<PrescriptionBean> list;
    Activity activity;
    LayoutInflater inflater = null;
    public PrescriptionAdapter(Activity activity, List<PrescriptionBean> newsList) {
        this.activity = activity;
        this.list = newsList;
        inflater = LayoutInflater.from(activity);
    }
    @Override
    public int getCount() {
        return list == null ? 0 : list.size();
    }

    @Override
    public Object getItem(int position) {
        if (list != null && list.size() != 0) {
            return list.get(position);
        }
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        PrescriptionBean item = list.get(position);
        ViewHolder holder;
        if(position%2==0){
            holder = ViewHolder.get(parent, convertView, R.layout.item_layout_prescription_bg, position);
        }else{
            holder = ViewHolder.get(parent, convertView, R.layout.item_layout_prescription, position);
        }

        TextView name = holder.getView(R.id.name);
        TextView content = holder.getView(R.id.content);
        TextView cishu = holder.getView(R.id.cishu);
        name.setText(item.getDutydoctor());
        cishu.setText(item.getType());
        content.setText(item.getName());
        return holder.getConvertView();
    }

}
